﻿#include <stdlib.h>

#include "shogi.h"

uint64 r64[32][256];

//------------------------------------------------------------
char Dir[12];
char LsDir[4096];

char Lsb12[4096];
char BitCnt12[4096];

//------------------------------------------------------------
// common_init()
//------------------------------------------------------------
void common_init()
{
  int i,j;

  Dir[NW_i]=NW;
  Dir[N_i]=N;
  Dir[NE_i]=NE;
  Dir[W_i]=W;
  Dir[E_i]=E;
  Dir[SW_i]=SW;
  Dir[S_i]=S;
  Dir[SE_i]=SE;
  Dir[NNW_i]=NNW;
  Dir[NNE_i]=NNE;
  Dir[SSW_i]=SSW;
  Dir[SSE_i]=SSE;

  for (i=0; i<4096; i++) {
    Lsb12[i]=-1;
    BitCnt12[i]=0;
    for (j=0; j<12; j++) {
      if (i&(1<<j)) {
        BitCnt12[i]++;
        if (BitCnt12[i]==1) {
          Lsb12[i]=j;
        }
      }
    }
  }

  for (i=0; i<4096; i++) {
    int lsb=Lsb12[i];
    LsDir[i]=Dir[lsb];
  }
}
